﻿CREATE TABLE [dbo].[DimTrack](
	[TrackId] [int] identity(1,1),
	[TrackCode] [int] NOT NULL,
	[Name] [nvarchar](200) NOT NULL,
	[AlbumId] [int] NOT NULL DEFAULT -1,
	[MediaTypeId] [int] NOT NULL DEFAULT -1,
	[GenreId] [int] NOT NULL DEFAULT -1,
	[Composer] [nvarchar](220) NULL,
	[Milliseconds] [int] NULL,
	[UnitPrice] [numeric](10, 2) NULL,
 [TaskExecutionLogId] INT NOT NULL DEFAULT 0, 
 [SCDEffectiveFrom] DATETIME NULL , 
    [SCDEffectiveTo] DATETIME NULL , 
    CONSTRAINT [PK_DimTrack] PRIMARY KEY CLUSTERED 
(
	[TrackId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[DimTrack]  WITH CHECK ADD  CONSTRAINT [FK_DimTrack_DimAlbumId] FOREIGN KEY([AlbumId])
REFERENCES [dbo].[DimAlbum] ([AlbumId])
GO

ALTER TABLE [dbo].[DimTrack] CHECK CONSTRAINT [FK_DimTrack_DimAlbumId]
GO

ALTER TABLE [dbo].[DimTrack]  WITH CHECK ADD  CONSTRAINT [FK_DimTrack_DimGenreId] FOREIGN KEY([GenreId])
REFERENCES [dbo].[DimGenre] ([GenreId])
GO

ALTER TABLE [dbo].[DimTrack] CHECK CONSTRAINT [FK_DimTrack_DimGenreId]
GO

ALTER TABLE [dbo].[DimTrack]  WITH CHECK ADD  CONSTRAINT [FK_DimTrack_DimMediaTypeId] FOREIGN KEY([MediaTypeId])
REFERENCES [dbo].[DimMediaType] ([MediaTypeId])
GO

ALTER TABLE [dbo].[DimTrack] CHECK CONSTRAINT [FK_DimTrack_DimMediaTypeId]
GO



